const globalIp = getApp().globalData.userIp
Page({

  /**
   * 页面的初始数据
   */
  data: {
    postNum: '0',
    entryNum: '0',
    leaveNum: '0'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  gridBtn(e) {
    console.log(e.currentTarget.dataset.num)
    if (e.currentTarget.dataset.num == 25) {
      wx.navigateTo({
        url: './roster/roster',
      })
    } else if (e.currentTarget.dataset.num == 26) {
      wx.navigateTo({
        url: './roster/roster?type=Y',
      })
    } else if (e.currentTarget.dataset.num == 27) {
      wx.navigateTo({
        url: './rosterleave/rosterleave',
      })
    } else {
      wx.showToast({
        title: '暂未开放！',
        icon: 'error'
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getManage();
  },

  getManage: function() {
    let that = this;
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    wx.request({
      url: globalIp + 'home/manage/ManageIndex',
      data: {
        openId: wx.getStorageSync('userInfo').openid,
        login: wx.getStorageSync('userInfo').login || 'N'
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        if (res.data.jsonObject) {
          var data = res.data.jsonObject.data;
          that.setData({
            postNum: data[0].postNum,
            entryNum: data[0].entryNum,
            leaveNum: data[0].leaveNum
          })
        }
      },
      fail: function(res) {
        wx.showToast({
          title: '请返回上一页面，重新请求',
          icon: 'none',
          duration: 2000,
        })
      },
      complete: function(res) {
        wx.hideLoading()
      }
    })
  }

})